The fs.rmdir() method is used to delete a directory in Node.js. However, it can only delete empty directories. To delete a directory with contents, you need to use additional code to recursively delete its contents before calling fs.rmdir(). Here's an example: